<pre><?
// ======================================================
// Put this file in your webcp 0.4.1 /cp directory and run it from your browser.
// The new database must be created first.
// INPUT NEW WEBCP INFO:
$cfg['webdir'] = '/home';
$cfg['webname'] = 'web';
$cfg['key'] = 'SECRET_KEY';
// ======================================================
echo "<pre>";
require("config.inc.php");
////////////////////////////////////////////////////////////////////////////////////////////////////
echo $table = 'domains';
echo "\n";
$dbp = mysql_query("SELECT * FROM $table");
while($data = mysql_fetch_array($dbp)) {
$ii = 0;
unset($newdata);
$newdata['id'] = $data['id'];
$newdata['owner'] = $data['owner'];
$newdata['priority'] = $data['priority'];
$newdata['ip'] = $data['ip'];
$newdata['host'] = $data['host'];
$newdata['host1'] = $data['host'];
$newdata['domain'] = $data['domain'];
$newdata['domain1'] = $data['domain'];
if (strstr($data['alias'],"#"))
	$nohost = 'true';
else
	$nohost = 'false';
if (strstr($data['alias'],"!") AND $nohost == 'true')
	$redirect = 'true';
else
	$redirect = 'false';
if (strstr($data['alias'],"*"))
	$catchall = 'true';
else
	$catchall = 'false';
$aliases = trim(eregi_replace("[[:space:]]+", " ", ereg_replace("(\*|\!|\#)","",$data['alias'])));
if ($aliases)
	$newdata['aliases'] = " $aliases ";
else
	$newdata['aliases'] = "";
$newdata['catchall'] = $catchall;
$newdata['nohost'] = $nohost;
$newdata['redirect'] = $redirect;
$newdata['defaultroot'] = $cfg['webdir']."/".$data['id']."/".$data['host']."/".$cfg['webname'];
if ($data['type'] == 'domain' AND $data['owner'] > 1000000000)
	$type = 'subdomain';
else
	$type = $data['type'];
$newdata['type'] = $type;
if ($type != 'pointer') {
	$path = explode("/",$data['path']);
	$path = "/".$path[1]."/".$path[2];
}
else
	$path = $data['path'];
$newdata['path'] = $path;
$newdata['transfer'] = $data['transfer_alloc'];
$newdata['transfer_used'] = $data['transfer_used'];
$newdata['transfer_stat'] = $data['transfer_stat'];
$newdata['hd'] = $data['hd_alloc'];
$newdata['users'] = $data['user_alloc'];
$newdata['subdomains'] = $data['subdomain_alloc'];
$newdata['pointers'] = $data['subdomain_alloc'];
$newdata['bandwidth'] = $data['bandwidth'];
unset($tmpdata);
if ($data['php'] == 'on')
	$tmpdata['php'] = 'on';
elseif ($data['php'] == 'off')
	$tmpdata['php'] = 'off';
else
	$tmpdata['php'] = 'na';
if ($data['asp'] == 'on')
	$tmpdata['asp'] = 'on';
elseif ($data['asp'] == 'off')
	$tmpdata['asp'] = 'off';
else
	$tmpdata['asp'] = 'na';
if ($data['perl'] == 'on')
	$tmpdata['asp'] = 'on';
elseif ($data['asp'] == 'off')
	$tmpdata['asp'] = 'off';
else
	$tmpdata['asp'] = 'na';
if ($data['ssi'] == 'on')
	$tmpdata['ssi'] = 'on';
elseif ($data['ssi'] == 'off')
	$tmpdata['ssi'] = 'off';
else
	$tmpdata['ssi'] = 'na';
if ($data['perl'] == 'on')
	$tmpdata['perl'] = 'on';
elseif ($data['perl'] == 'off')
	$tmpdata['perl'] = 'off';
else
	$tmpdata['perl'] = 'na';
if ($data['ssl'] == 'on')
	$tmpdata['ssl'] = 'on';
elseif ($data['ssl'] == 'off')
	$tmpdata['ssl'] = 'off';
else
	$tmpdata['ssl'] = 'na';
$newdata['serverside'] = addslashes(serialize($tmpdata));
$newdata['db'] = $data['user_alloc'];
$newdata['shell']  = "na";
$newdata['httpcustom'] = $data['custom'];
$newdata['email'] = $data['email'];
$newdata['suspended'] = $data['hold'];
unset($sql_query);
reset($newdata);
foreach($newdata AS $key=>$val)
	$sql_query .= "$key = '$val', ";
$sql_query = "INSERT INTO domains SET $sql_query time = ''";
mysql_select_db('webcp');
mysql_query($sql_query) or die(mysql_error());
mysql_select_db('cp');
}
echo "\n\n";
///////////////////////////////////////////////////////////////////////
echo $table = 'reseller';
echo "\n";
$dbp = mysql_query("SELECT * FROM $table");
while($data = mysql_fetch_array($dbp)) {
$ii = 0;
unset($newdata);
$newdata['id'] = $data['id'];
$newdata['name'] = addslashes($data['name']);
$newdata['email'] = $data['email'];
$newdata['ip'] = '24.215.1.50';
$newdata['domains'] = $data['domain_alloc'];
$newdata['subdomains'] = $data['subdomain_alloc'];
$newdata['pointers'] = $data['subdomain_alloc'];
$newdata['users'] = $data['user_alloc'];
$newdata['hd'] = $data['hd_alloc'];
$newdata['transfer'] = $data['transfer_alloc'];
$newdata['bandwidth'] = $data['bandwidth'];
unset($tmpdata);
if ($data['php'] == 'on')
	$tmpdata['php'] = 'on';
elseif ($data['php'] == 'off')
	$tmpdata['php'] = 'off';
else
	$tmpdata['php'] = 'na';
if ($data['asp'] == 'on')
	$tmpdata['asp'] = 'on';
elseif ($data['asp'] == 'off')
	$tmpdata['asp'] = 'off';
else
	$tmpdata['asp'] = 'na';
if ($data['perl'] == 'on')
	$tmpdata['asp'] = 'on';
elseif ($data['asp'] == 'off')
	$tmpdata['asp'] = 'off';
else
	$tmpdata['asp'] = 'na';
if ($data['ssi'] == 'on')
	$tmpdata['ssi'] = 'on';
elseif ($data['ssi'] == 'off')
	$tmpdata['ssi'] = 'off';
else
	$tmpdata['ssi'] = 'na';
if ($data['perl'] == 'on')
	$tmpdata['perl'] = 'on';
elseif ($data['perl'] == 'off')
	$tmpdata['perl'] = 'off';
else
	$tmpdata['perl'] = 'na';
if ($data['ssl'] == 'on')
	$tmpdata['ssl'] = 'on';
elseif ($data['ssl'] == 'off')
	$tmpdata['ssl'] = 'off';
else
	$tmpdata['ssl'] = 'na';
$newdata['serverside'] = addslashes(serialize($tmpdata));
$newdata['db'] = $data['user_alloc'];
$newdata['shell'] = 'na';
$newdata['skin'] = 'any';
unset($sql_query);
reset($newdata);
foreach($newdata AS $key=>$val)
	$sql_query .= "$key = '$val', ";
$sql_query = "INSERT INTO resellers SET $sql_query lastchange = ''";
mysql_select_db('webcp');
mysql_query($sql_query) or die(mysql_error());
mysql_select_db('cp');
}
echo "\n\n";
///////////////////////////////////////////////////////////////////////////////////
echo $table = 'users';
echo "\n";
$dbp = mysql_query("SELECT * FROM $table");
while($data = mysql_fetch_array($dbp)) {
$ii = 0;
unset($newdata);
$newdata['username'] = $data['username'];
$newdata['username1'] = $data['username'];
$temppass = trim(mcrypt_ecb(MCRYPT_3DES, $cryptkey, base64_decode($data['password']), MCRYPT_DECRYPT));
$temppass = "password=ENCODE('".$temppass."','".$cfg['key']."')";
$newdata['id'] = $data['parent'];;
$newdata['name'] = addslashes($data['name']);
if (strstr($data['type'],'level0'))
	$newdata['level'] = 0;
elseif (strstr($data['type'],'level1'))
	$newdata['level'] = 1;
elseif (strstr($data['type'],'level2'))
	$newdata['level'] = 2;
elseif (strstr($data['type'],'level3'))
	$newdata['level'] = 3;
else
	$newdata['level'] = 4;
if (strstr($data['type'],'demo'))
	$newdata['type'] = 'demo';
else
	$newdata['type'] = 'standard';
$newdata['shell'] = 'na';
$newdata['root'] = $data['root'];
$newdata['hd'] = $data['hd'];
$aliases = trim(eregi_replace("[[:space:]]+", " ", ereg_replace("(\*|\!|\#)","",$data['alias'])));
if ($aliases)
	$newdata['aliases'] = " $aliases ";
else
	$newdata['aliases'] = "";
if (strstr($data['alias'],"*"))
	$newdata['catchall'] = 'true';
else
	$newdata['catchall'] = 'false';
$newdata['autoreply'] = addslashes($data['autoreply']);
$forward = trim(eregi_replace("[[:space:]]+", " ", $data['forward']));
if ($forward)
	$newdata['forward'] = " $forward ";
else
	$newdata['forward'] = "";
$newdata['lang'] = 'english';
$newdata['skin'] = 'greenclassic';
$newdata['suspend'] = $data['hold'];
unset($sql_query);
reset($newdata);
foreach($newdata AS $key=>$val)
	$sql_query .= "$key = '$val', ";
$sql_query = "INSERT INTO users SET $sql_query $temppass";
mysql_select_db('webcp');
mysql_query($sql_query) or die(mysql_error());
mysql_select_db('cp');
}
echo "\n..done\n\n";
?></pre>
